#pragma once
#include <GL/glew.h>
#include "CgProgram.h"
#include "RenderTexture.h"

const int __PGORDER[][2] = {{1, 0}, {0, 2}, {2, 2}, {1, 2}, {1, 1},
{0, 0}, {2, 1}, {2, 0}, {0, 1}};
//const int __PGORDER[][2] = {{0, 0}, {2, 2}, {2, 2}, {1, 2}, {1, 1},
//{0, 0}, {2, 1}, {2, 0}, {0, 1}};

class ParallelPoison
{
	GLuint* randTexIds;
	GLuint randId;
	int kTrial;
	CgProgram* s_subdivideProgram;
	CgProgram* s_dartthrowProgram;
	CgProgram* s_renderQuadVertexProgram;
public:
	IteratedRenderTexture* M;
public:
	ParallelPoison(void);
	~ParallelPoison(void);

	GLuint process(int w, int h, float rmin);
	void genRandomVal(int l);
	void genRandomId(float &cid, int level);
};
